package com.ruoyi.labdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabChemicalUse;
import com.ruoyi.labdata.service.ILabChemicalUseService;

/**
 * 化学品使用Controller
 * 
 * @author winner pan
 * @date 2022-03-18
 */
@RestController
@RequestMapping("/labdata/chemicalUse")
public class LabChemicalUseController extends BaseController {
	@Autowired
	private ILabChemicalUseService labChemicalUseService;

	/**
	 * 查询化学品使用列表
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:using:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabChemicalUse labChemicalUse) {
		startPage();
		List<LabChemicalUse> list = labChemicalUseService.selectLabChemicalUseList(labChemicalUse);
		return getDataTable(list);
	}

	/**
	 * 导出化学品使用列表
	 */
	/*
	 * @PreAuthorize("@ss.hasPermi('labdata:chemicalUse:export')")
	 * 
	 * @Log(title = "化学品使用", businessType = BusinessType.EXPORT)
	 * 
	 * @GetMapping("/export") public AjaxResult export(LabChemicalUse
	 * labChemicalUse) { List<LabChemicalUse> list =
	 * labChemicalUseService.selectLabChemicalUseList(labChemicalUse);
	 * ExcelUtil<LabChemicalUse> util = new
	 * ExcelUtil<LabChemicalUse>(LabChemicalUse.class); return
	 * util.exportExcel(list, "chemicalUse"); }
	 */

	/**
	 * 获取化学品使用详细信息
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:using:edit')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult.success(labChemicalUseService.selectLabChemicalUseById(id));
	}

	/**
	 * 新增化学品使用
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:using:edit')")
	@Log(title = "化学品使用", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabChemicalUse labChemicalUse) {
		return toAjax(labChemicalUseService.insertLabChemicalUse(labChemicalUse));
	}

	/**
	 * 修改化学品使用
	 */
	/*
	 * @PreAuthorize("@ss.hasPermi('labdata:chemicalUse:edit')")
	 * 
	 * @Log(title = "化学品使用", businessType = BusinessType.UPDATE)
	 * 
	 * @PutMapping public AjaxResult edit(@RequestBody LabChemicalUse
	 * labChemicalUse) { return
	 * toAjax(labChemicalUseService.updateLabChemicalUse(labChemicalUse)); }
	 */
	/**
	 * 删除化学品使用
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:using:delete')")
	@Log(title = "化学品使用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable long ids) {
		return toAjax(labChemicalUseService.deleteLabChemicalUseById(ids));
	}
}
